<template>
  <div>
    <van-contact-card
      v-if="address.orderAddress"
      type="edit"
      :tel="address.orderAddress.tel"
      :name="address.orderAddress.name"
      @click="handleAddressList"
    />
    <van-contact-card type="add" @click="handleAddressList" v-else />

    <van-card
      v-for="item in checkList"
      :num="item.num"
      :price="item.originprice"
      :title="item.proname"
      :thumb="item.img1"
    />
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import { useCart } from "../store/cart";
import { computed } from "vue";
import { CartProductType } from "../types/prod";
import { useAddress } from "../store/address";
const router = useRouter();
const handleAddressList = () => {
  router.push("/address");
};

// 地址显示
const address = useAddress();

// 获取用户勾选的商品 computed、getters
const cart = useCart();
const checkList = computed<CartProductType[]>(() =>
  cart.cartList.filter((item) => item.ischeck)
);
</script>

<style scoped></style>
